package com.lgx.mall.business.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import net.sf.json.JSONObject;

import com.lgx.common.entity.IdGenerator;
import com.lgx.common.web.util.DateUtils;

/**
 * 消费信息
 * @author pengdeyi
 *
 */
@Entity
@Table(name="TM_CONSUMERINFO")
public class ConsumerInfo implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator=IdGenerator.TM_CONSUMERINFO_ID)
	@TableGenerator(
			name = IdGenerator.TM_CONSUMERINFO_ID,
			table = IdGenerator.GENERATOR_TABLE,
			pkColumnName = IdGenerator.GEN_NAME,
			pkColumnValue = IdGenerator.TM_CONSUMERINFO_ID,
			valueColumnName = IdGenerator.GEN_VALUE,
			initialValue = 1,
			allocationSize = 1
	)
	private long id;//系统编号
	
	//消费用户ID
	@Column(name="member_id")
	private long userId;
	
	private String trueName;//消费用户真实姓名
	
	private String userMobile;//消费用户手机号
	
	private String userCardId;//消费用户卡号
	
	//消费商家
	@Column(name="merchant_id")
	private long orgId;
	
	private String orgName;//消费商家名称
	
	private String orgType;//消费商家类型
	
	private double amount;//消费金额
	
	private double score;//获得积分数
	
	/**
	 * 1本卡消费，2外卡消费
	 */
	private String type;//消费类型
	
	private Date consumerTime;//消费时间
	
	private String remarks;//备注
	
	private String isDelete;//删除标注

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public String getTrueName() {
		return trueName;
	}

	public void setTrueName(String trueName) {
		this.trueName = trueName;
	}

	public String getUserMobile() {
		return userMobile;
	}

	public void setUserMobile(String userMobile) {
		this.userMobile = userMobile;
	}

	public String getUserCardId() {
		return userCardId;
	}

	public void setUserCardId(String userCardId) {
		this.userCardId = userCardId;
	}

	public long getOrgId() {
		return orgId;
	}

	public void setOrgId(long orgId) {
		this.orgId = orgId;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getOrgType() {
		return orgType;
	}

	public void setOrgType(String orgType) {
		this.orgType = orgType;
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount = amount;
	}

	public double getScore() {
		return score;
	}

	public void setScore(double score) {
		this.score = score;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Date getConsumerTime() {
		return consumerTime;
	}

	public void setConsumerTime(Date consumerTime) {
		this.consumerTime = consumerTime;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(String isDelete) {
		this.isDelete = isDelete;
	}
	
	//消费时间
	public String time(){
		return DateUtils.dateToChar(getConsumerTime(), DateUtils.DATE_FORMAT_D);
	}
	
	@Override
	public String toString() {
		JSONObject obj = new JSONObject();
		
		obj.put("trueName", this.getTrueName());
		obj.put("userCardId", this.getUserCardId());
		obj.put("amount", this.getAmount());
		obj.put("score", this.getScore());
		obj.put("consumerTime", this.getConsumerTime()!=null?DateUtils.dateToChar(this.getConsumerTime(), DateUtils.DATE_FORMAT_T):"");
		obj.put("orgName", this.getOrgName());
		return obj.toString();
	}
}
